<?php

class TestWrongObjectApp implements Base\AppConfiguration
{
    public $fail = 'none';
    
    function createRequestParser()
    {
        return ( $this->fail === 'request-parser' ) ? new stdClass() : new testRequestParser();
    }
    
    function createRouter( Core\MVCRequest $request )
    {
        if( $this->fail === 'fatal' ) return new testExceptionInActionRouter( $request );
        
        if( $this->fail === 'controller' ) return new testBrokenControllerRouter( $request );
        
        return ( $this->fail === 'router' )? new stdClass() : new testRouter( $request );
    }
    
    function createView( Implementation\RoutingInformation $routeInfo, Core\MVCRequest $request, Entity\MvcResult $result )
    {
        return ( $this->fail === 'view' )? new stdClass : new testView( $request, $result );
    }
    
    function createResponseWriter( Implementation\RoutingInformation $routeInfo, Core\MVCRequest $request, Entity\MvcResult $result, Entity\Response $response )
    {
        $responseWriter = ( $this->fail === 'response-writer' )? new stdClass() : new testResponseWriter( $response );
        $responseWriter->config = $this;
        
        return $responseWriter;
    }
    
    function createFatalRedirectRequest( Core\MVCRequest $request, Entity\MvcResult $result, \Exception $e )
    {
        return ( $this->fail === 'fatal' )? new stdClass() : new Core\MVCRequest();
    }
    
    function runPreRoutingFilters( Core\MVCRequest $request )
    {
    }
    
    function runRequestFilters( Implementation\RoutingInformation $routeInfo, Core\MVCRequest $request )
    {
    }
    
    function runResultFilters( Implementation\RoutingInformation $routeInfo, Core\MVCRequest $request, Entity\MvcResult $result )
    {
    }
    
    function runResponseFilters( Implementation\RoutingInformation $routeInfo, Core\MVCRequest $request, Entity\MvcResult $result, Entity\Response $response )
    {
    }
}
